package com.xxx.control.application;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import androidx.multidex.MultiDex;

import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.Utils;
import com.gg.reader.api.dal.GClient;
import com.xxx.control.bean.GatewayInitResponse;
import com.xxx.control.config.Config;
import com.xxx.control.constant.Constant;
import com.xxx.control.crash.CrashHandler;
import com.xxx.control.crash.FileUtil;


/**
 * Create by Sxl on 2021/12/21.
 */
public class App extends Application {

    private static Context instance;

    public static Context getContext() {
        return instance;
    }

    public GClient client = new GClient();
    public GClient clientSecond = new GClient();
    public static GatewayInitResponse gatewayInitResponse;

    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
        instance = this;
        Utils.init(this);
        CrashUtils.init();
        LogUtils.getConfig().setLog2FileSwitch(true);
        LogUtils.getConfig().setSaveDays(7);

        client.setSerialNumber("readerA");
        clientSecond.setSerialNumber("readerB");

        Config.baseUrl = SPUtils.getInstance().getString(Constant.IP_ADDRESS, "http://140.143.171.108:8030/");
    }

    /**
     * 重写 getResource 方法，防止系统字体影响
     */
    @Override
    public Resources getResources() {//禁止app字体大小跟随系统字体大小调节
        Resources resources = super.getResources();
        if (resources != null && resources.getConfiguration().fontScale != 1.0f) {
            android.content.res.Configuration configuration = resources.getConfiguration();
            configuration.fontScale = 1.0f;
            resources.updateConfiguration(configuration, resources.getDisplayMetrics());
        }
        return resources;
    }
}
